package schema

import (
	"time"

	"entgo.io/ent"
	"entgo.io/ent/dialect/entsql"
	"entgo.io/ent/schema"
	"entgo.io/ent/schema/field"
)

// WorkTimeSetting 保存工作时间设置
type WorkTimeSetting struct {
	ent.Schema
}

// Fields of the WorkTimeSetting
func (WorkTimeSetting) Fields() []ent.Field {
	return []ent.Field{
		field.Int64("id").
			Positive().
			Unique().
			Immutable().
			Comment("设置ID"),
		// 修改为string类型来存储TIME类型字段
		field.String("check_in_start").
			Default("08:30:00").
			Comment("上班打卡开始时间"),
		field.String("check_in_end").
			Default("09:30:00").
			Comment("上班打卡结束时间"),
		field.String("check_out_start").
			Default("17:30:00").
			Comment("下班打卡开始时间"),
		field.String("check_out_end").
			Default("18:30:00").
			Comment("下班打卡结束时间"),
		field.Bool("is_active").
			Default(true).
			Comment("是否启用"),
		field.Time("created_at").
			Default(time.Now).
			Immutable().
			Comment("创建时间"),
		field.Time("updated_at").
			Default(time.Now).
			UpdateDefault(time.Now).
			Comment("更新时间"),
	}
}

// Annotations of the WorkTimeSetting
func (WorkTimeSetting) Annotations() []schema.Annotation {
	return []schema.Annotation{
		entsql.Annotation{
			Table: "work_time_settings",
		},
	}
}
